package com.ljp.usercenter.config;

import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName: WebMvcConfig
 * Package: com.ljp.usercenter.config
 * Description:
 *
 * @Author: ljp
 * @Create: 2023/5/15-下午 06:20
 * @Version: 1.0
 */
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry){
        //设置允许跨域的请求
        registry.addMapping("/**")
                //设置允许跨域请求的域名
                .allowedOrigins("http://120.27.150.4")
                //是否允许证书，默认关闭
                .allowCredentials(true)
                //允许跨域的请求方式
                .allowedMethods("*")
                //跨域允许时间
                .maxAge(3600);
        //registry.addMapping("/**")
        //        .allowedOrigins("*")
        //        .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
        //        .allowCredentials(true)
        //        .maxAge(3600)
        //        .allowedHeaders("*");
    }

}
